import helper.base.CloneHelper.Cloneable
import helper.base.CloneHelper.Expand.CloneableList.cloneList
import helper.base.CloneHelper.Expand.StringList.cloneList
import org.junit.Test

internal class CloneTest {
    private data class NA(
        val ns: ArrayList<String>
    ) : Cloneable {
        override fun clone(): NA {
            return NA(ns.cloneList())
        }
    }

    private data class CA(
        val aList: ArrayList<String>,
        val ns: List<NA>,
    ) : Cloneable {
        override fun clone(): CA {
            return CA(
                aList.cloneList(),
                ns.cloneList(),
            )
        }
    }

    @Test
    fun t1() {
        val a1 = arrayListOf("s1", "s2")
        val n1a = arrayListOf("n1a1", "n1a2")
        val n2a = arrayListOf("n2a1", "n2a2")
        val ns = arrayListOf(NA(n1a), NA(n2a))
        val ca1 = CA(a1, ns)
        val ca2 = ca1.clone()
        n1a.add("a1a3")
        val n3a = arrayListOf("n3a1", "n3a2")
        ns.add(NA(n3a))
        ca1.aList.add("s3")
        println(ca1)
        println(ca2)
    }
}